#define _CRT_SECURE_NO_WARNINGS 1


#include <string>
using namespace std;
class Solution {
public:
    string reverseWords(string s) {
        int f = 0;
        int b = s.find_first_of(' ', f);
        while (b != -1)
        {
            reverse(s.begin() + f, s.begin() + b);
            f = b + 1;
            b = s.find_first_of(' ', f);
            //cout << s<<endl;
        }
        reverse(s.begin() + f, s.end());
        return s;
    }
};